home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: meaning of int a::*b
- Date: 20 Feb 1996 18:13:58 GMT
- Organization: Borland International
- Message-ID: <4gd316$f3p@druid.borland.com>
- References: <31284007.7977@mercury.co.il>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <31284007.7977@mercury.co.il>, wygodny@mercury.co.il says...
- >
- >In the following (compilable) program:
- >
- >class a{};
- >int a::*b;
- >void main(){}
- >
- >Does someone know what is the meaning of int a::*b; ?
- >It's probably a declaration of a variable b of type int a::* .
- >But what
- >does it mean? What can be assigned to it?
-
- It's a pointer to a member of a of type int. You can assign it the address of
- a member of a of type int:
-
- class A
- {
- public:
- int i;
- int j;
- };
-
- int main()
- {
- A a;
- int A::*aptr = &A::i;
- a.*aptr = 3; // assign 3 to a.i
- aptr = &A::j;
- a.*aptr = 4; // assign 4 to a.j
- return 0;
- }
-
-